package hu.arguscab.graphic;

import java.awt.Color;
import hu.arguscab.physic.Angle;
import hu.arguscab.physic.Vector;
import static org.lwjgl.opengl.GL11.*;

/**
 *
 * @author sharp
 */
public abstract class DrawablePrimitive implements Drawable {

	int x, y;
	int angle;
	float r, g, b;
	float lineWidth = 1.0f;

	public void setColor(float r, float g, float b) {
		this.r = r;
		this.g = g;
		this.b = b;
	}

	public void setColor(Color c) {
		this.r = c.getRed()/255.0f;
		this.g = c.getGreen()/255.0f;
		this.b = c.getBlue()/255.0f;
	}

	public int getAngle() {
		return angle;
	}

	public void setAngle(int angle) {
		this.angle = angle;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public void setPos(Vector pos) {
		x = (int) pos.getX();
		y = (int) pos.getY();
	}

	
	
	public float getLineWidth() {
		return lineWidth;
	}

	public void setLineWidth(float lineWidth) {
		this.lineWidth = lineWidth;
	}

	@Override
	public void draw() {

		glPushMatrix();
		glTranslatef(x, y, 0);
		glRotatef(angle, 0, 0, 1);
		glColor3f(r, g, b);
		glLineWidth(lineWidth);

		glBegin(getGLType());
			drawImpl();
		glEnd();

		glLineWidth(1.0f);
		glColor3f(1, 1, 1);
		glPopMatrix();
	}

	public abstract int getGLType();
	public abstract void drawImpl();
}
